/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sys.screen;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import sys.bean.ContasReceberBean;
import sys.bean.UsuarioBean;
import sys.dao.ContasReceberDao;
import sys.dao.UsuarioDao;
import sys.utils.Mensagens;
import sys.utils.Utils;
import static sys.utils.Utils.escClose;
import static sys.utils.Utils.numParaCalculos;

/**
 *
 * @author Administrador
 */
public class UIAnalisaDescRecebimentos extends javax.swing.JDialog {

    SimpleDateFormat formDataSpac = new SimpleDateFormat("yyyyMMdd");
    SimpleDateFormat formatoTCCaixa = new SimpleDateFormat("yyMMdd");
    NumberFormat formatoMoeda = NumberFormat.getCurrencyInstance();
    private List<UsuarioBean> listaVendedores;
    String idVendedor = "";

    /**
     * Creates new form UIAnalisaDescRecebimentos
     *
     * @param parent
     * @param modal
     */
    public UIAnalisaDescRecebimentos(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        escClose(this);
        setLocationRelativeTo(null);
        UIManager.put("Table.alternateRowColor", new java.awt.Color(230, 255, 255));
        dataInicial.setDate(new Date());
        dataFinal.setDate(new Date());
        atualizaVendedores();
        Utils.maximizarDialog(this);
    }

    public UIAnalisaDescRecebimentos(java.awt.Frame parent, boolean modal, Date dtInicial, Date dtFinal, int posVendedor) {
        super(parent, modal);
        initComponents();
        escClose(this);
        setLocationRelativeTo(null);
        UIManager.put("Table.alternateRowColor", new java.awt.Color(230, 255, 255));
        atualizaVendedores();
        dataInicial.setDate(dtInicial);
        dataFinal.setDate(dtFinal);
        cbVendedor.setSelectedIndex(posVendedor + 1);
        jtabbedPane.setSelectedIndex(1);
        atualizaVales();
         Utils.maximizarDialog(this);
    }

    private void somaTabela() {
        double soma = 0;
        int[] linhas = tabelaSintetico.getSelectedRows();
        for (int i = 0; i < linhas.length; i++) {
            soma += Double.parseDouble(numParaCalculos(tabelaSintetico.getValueAt(linhas[i], 8).toString()));
        }
        lbSoma.setText("TOTAL DE DESCONTO: " + formatoMoeda.format(soma));
    }

    private void atualizaVales() {
        if (jtabbedPane.getSelectedIndex() == 0) {
            final BarraProgresso pb = new BarraProgresso(this);
            SwingWorker worker = new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                    pb.gerarJanela();
                    pb.lbDescricao.setText("ANALISANDO, POR FAVOR AGUARDE...");
                    atualizaTabelaAnalitico();
                    return null;
                }

                @Override
                protected void done() {
                    pb.fechar();
                }
            };
            worker.execute();
        } else {
            final BarraProgresso pb = new BarraProgresso(this);
            SwingWorker worker = new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                    pb.gerarJanela();
                    pb.lbDescricao.setText("ANALISANDO, POR FAVOR AGUARDE...");
                    atualizaTabelaSintetico(retVendedorCombo());
                    return null;
                }

                @Override
                protected void done() {
                    pb.fechar();
                }
            };
            worker.execute();
        }
    }

    /*
     foi necessário criar o método pois não é possível carregar tela de "carregando" diretamente
     */
    private void chamaAnaPedidos() {
        UIAnalisaPedidos uiap = new UIAnalisaPedidos(this, true);
        uiap.txPedido.setText(tabelaSintetico.getValueAt(tabelaSintetico.getSelectedRow(), 1).toString());
        uiap.setVisible(true);
    }

    private String retVendedorCombo() {
        if (cbVendedor.getSelectedIndex() == 0) {
            idVendedor = "";
        } else {
            idVendedor = listaVendedores.get(cbVendedor.getSelectedIndex() - 1).getCodigo();
        }
        return idVendedor;
    }

    private String retVendedorTabela() {
        return tabelaAnalitico.getValueAt(tabelaAnalitico.getSelectedRow(), 0).toString().substring(0, 3);
    }

    private void atualizaVendedores() {
        try {
            cbVendedor.removeAllItems();
            cbVendedor.addItem("<< TODOS OS VENDEDORES >>");
            listaVendedores = UsuarioDao.getListaComboVendedores();

            for (UsuarioBean usu : listaVendedores) {
                cbVendedor.addItem(usu.getCodigo() + " - " + usu.getNome());
            }
        } catch (IOException | SQLException ex) {
            Mensagens.msgErro("erro\n" + ex.getMessage());
        }
    }

    private void atualizaTabelaAnalitico() {
        DefaultTableModel modelo = (DefaultTableModel) tabelaAnalitico.getModel();
        modelo.setNumRows(0);

        try {
            for (ContasReceberBean cReceber : ContasReceberDao.descJurosRecAnalitico(formDataSpac.format(dataInicial.getDate()), formDataSpac.format(dataFinal.getDate()), retVendedorCombo())) {
                modelo.addRow(new Object[]{
                    cReceber.getPedido().getUsuario().getNome(), formatoMoeda.format(cReceber.getDescRecebimentos()).replace("R$", "")
                });
            }

            DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();

            centralizado.setHorizontalAlignment(SwingConstants.CENTER);
            tabelaAnalitico.getColumnModel().getColumn(1).setCellRenderer(centralizado);
            tabelaAnalitico.getColumnModel().getColumn(2).setCellRenderer(centralizado);

        } catch (SQLException | IOException ex) {
            Mensagens.msgErro("erro\n" + ex.getMessage());
        }

    }

    private void atualizaTabelaSintetico(String vendedor) {

        DefaultTableModel modelo = (DefaultTableModel) tabelaSintetico.getModel();
        modelo.setNumRows(0);

        try {
            for (ContasReceberBean cReceber : ContasReceberDao.descJurosRecSintetico(formDataSpac.format(dataInicial.getDate()), formDataSpac.format(dataFinal.getDate()), vendedor)) {
                modelo.addRow(new Object[]{
                    cReceber.getCaixa().getUsuario().getNome(), cReceber.getnDocumento(), cReceber.getCliente().getNome(), cReceber.getDataCompra(), cReceber.getDataVencimento(),
                    cReceber.getDataPagamento(), formatoMoeda.format(cReceber.getVrParcela()).replace("R$", ""), formatoMoeda.format(cReceber.getVrPago()).replace("R$", ""),
                    formatoMoeda.format(cReceber.getDescRecebimentos()).replace("R$", "")

                });
            }

            DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();

            centralizado.setHorizontalAlignment(SwingConstants.CENTER);
            tabelaSintetico.getColumnModel().getColumn(1).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(3).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(4).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(5).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(6).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(7).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(8).setCellRenderer(centralizado);
            tabelaSintetico.getColumnModel().getColumn(9).setCellRenderer(centralizado);

        } catch (SQLException | IOException ex) {
            Mensagens.msgErro("erro\n" + ex.getMessage());
        }

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jpDados = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        dataInicial = new com.toedter.calendar.JDateChooser("dd/MM/yyyy", "##/##/#####", '_');
        jLabel5 = new javax.swing.JLabel();
        cbVendedor = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        dataFinal = new com.toedter.calendar.JDateChooser("dd/MM/yyyy", "##/##/#####", '_');
        lbSoma = new javax.swing.JLabel();
        jtabbedPane = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaAnalitico = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabelaSintetico = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        btnSalvar = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("ANÁLISE DE DESCONTO/JUROS RECEBIMENTO");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jpDados.setBackground(new java.awt.Color(255, 255, 255));
        jpDados.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "SELECIONE DADOS:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel2.setText("DATA INICIAL:");

        dataInicial.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N

        jLabel5.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel5.setText("VENDEDOR:");

        cbVendedor.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        cbVendedor.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<< TODOS OS VENDEDORES >>" }));

        jLabel3.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel3.setText("DATA FINAL:");

        dataFinal.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N

        lbSoma.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        lbSoma.setForeground(new java.awt.Color(204, 0, 255));
        lbSoma.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        javax.swing.GroupLayout jpDadosLayout = new javax.swing.GroupLayout(jpDados);
        jpDados.setLayout(jpDadosLayout);
        jpDadosLayout.setHorizontalGroup(
            jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpDadosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(dataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(dataFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpDadosLayout.createSequentialGroup()
                        .addComponent(cbVendedor, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lbSoma, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jpDadosLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(jLabel5)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jpDadosLayout.setVerticalGroup(
            jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpDadosLayout.createSequentialGroup()
                .addGroup(jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpDadosLayout.createSequentialGroup()
                        .addGroup(jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbVendedor)
                            .addGroup(jpDadosLayout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(dataFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jpDadosLayout.createSequentialGroup()
                                .addComponent(lbSoma, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jpDadosLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jtabbedPane.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N

        tabelaAnalitico.setAutoCreateRowSorter(true);
        tabelaAnalitico.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        tabelaAnalitico.setForeground(new java.awt.Color(51, 102, 255));
        tabelaAnalitico.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "VENDEDOR", "DESCONTO EM CAIXA"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaAnalitico.setGridColor(new java.awt.Color(204, 204, 204));
        tabelaAnalitico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelaAnaliticoMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tabelaAnalitico);
        if (tabelaAnalitico.getColumnModel().getColumnCount() > 0) {
            tabelaAnalitico.getColumnModel().getColumn(0).setPreferredWidth(200);
        }

        jtabbedPane.addTab("ANALÍTICO", jScrollPane1);

        tabelaSintetico.setAutoCreateRowSorter(true);
        tabelaSintetico.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        tabelaSintetico.setForeground(new java.awt.Color(51, 102, 255));
        tabelaSintetico.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "VENDEDOR", "NR. DOCUMENTO", "CLIENTE", "COMPRA", "VENCIMENTO", "PAGAMENTO", "VR. PARCELA", "VR. PAGO", "DESCONTO"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaSintetico.setGridColor(new java.awt.Color(204, 204, 204));
        tabelaSintetico.getTableHeader().setReorderingAllowed(false);
        tabelaSintetico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelaSinteticoMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tabelaSinteticoMouseReleased(evt);
            }
        });
        tabelaSintetico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tabelaSinteticoKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(tabelaSintetico);
        if (tabelaSintetico.getColumnModel().getColumnCount() > 0) {
            tabelaSintetico.getColumnModel().getColumn(2).setPreferredWidth(250);
        }

        jtabbedPane.addTab("SINTÉTICO", jScrollPane2);

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));

        btnSalvar.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/picture/find-2.png"))); // NOI18N
        btnSalvar.setText("BUSCAR");
        btnSalvar.setPreferredSize(new java.awt.Dimension(120, 30));
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });
        jPanel4.add(btnSalvar);

        btnSair.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/picture/sair.png"))); // NOI18N
        btnSair.setText("SAIR");
        btnSair.setPreferredSize(new java.awt.Dimension(120, 30));
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });
        jPanel4.add(btnSair);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 981, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jpDados, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpDados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tabelaAnaliticoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaAnaliticoMouseClicked

        if (evt.getClickCount() == 2) {

            final BarraProgresso pb = new BarraProgresso(this);
            SwingWorker worker = new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                    pb.gerarJanela();
                    pb.lbDescricao.setText("CARREGANDO, POR FAVOR AGUARDE...");
                    atualizaTabelaSintetico(retVendedorTabela());
                    jtabbedPane.setSelectedIndex(1);
                    return null;
                }

                @Override
                protected void done() {
                    pb.fechar();
                }
            };
            worker.execute();

        }
    }//GEN-LAST:event_tabelaAnaliticoMouseClicked

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
        atualizaVales();
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnSairActionPerformed

    private void tabelaSinteticoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaSinteticoMouseClicked
        if ((evt.getModifiers() & java.awt.event.MouseEvent.BUTTON3_MASK) != 0) {
            JPopupMenu menu = new JPopupMenu();
            JMenuItem menuAnaPedido = new JMenuItem("ANALISAR");
            menuAnaPedido.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/picture/find.png")));
            menuAnaPedido.setFont(new java.awt.Font("Calibri", 0, 12));

            menu.add(menuAnaPedido);

            menuAnaPedido.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    chamaAnaPedidos();
                }
            });
            menu.show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }//GEN-LAST:event_tabelaSinteticoMouseClicked

    private void tabelaSinteticoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaSinteticoMouseReleased
        somaTabela();
    }//GEN-LAST:event_tabelaSinteticoMouseReleased

    private void tabelaSinteticoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tabelaSinteticoKeyReleased
        somaTabela();
    }//GEN-LAST:event_tabelaSinteticoKeyReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSair;
    private javax.swing.JButton btnSalvar;
    private javax.swing.JComboBox cbVendedor;
    private com.toedter.calendar.JDateChooser dataFinal;
    private com.toedter.calendar.JDateChooser dataInicial;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JPanel jpDados;
    private javax.swing.JTabbedPane jtabbedPane;
    private javax.swing.JLabel lbSoma;
    private javax.swing.JTable tabelaAnalitico;
    private javax.swing.JTable tabelaSintetico;
    // End of variables declaration//GEN-END:variables
}
